package com.yihen.mappers;

import com.yihen.pojo.Doctor;
import com.yihen.pojo.Patient;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface PatientMapper {
    /**
     * 根据医生id查询出该医生处理的所有病人
     * @param  id  医生id
     * @return java.util.List<com.yihen.pojo.Patient>
     * @author 懿痕
     * @time 2022/10/24 16:43
     */
    public List<Patient> queryAllPatientsByid(@Param("id") long id);

    // 条件查询患者信息
    public List<Patient> queryPatientsByCondition(@Param("patient") Patient patient);

    // 批量删除患者信息
    public int deleteByIds(@Param("ids") List<Long> ids);

    // 查询所有患者
    @Select("select * from tb_patient")
    public List<Patient> queryAllPatients();

    // 添加患者
    @Update("insert into tb_patient values(#{patient.id},#{patient.name},#{patient.gender})")
    public int insert(@Param("patient") Patient patient);

    // 删除患者
    @Update("delete from tb_patient where id =#{id }")
    public int deleteById(@Param("id") long id);

    // 修改患者信息
    @Update("update tb_patient set name=#{patient.name},gender=#{patient.gender} where id =#{patient.id}")
    public int update(@Param("patient") Patient patient);

    // 根据id获取患者信息
    @Select("select * from tb_patient where id =#{id}")
    public Patient queryPatientById(@Param("id") long id);

}
